<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>Show</title>
</head>

<body>
    <script type="text/javascript">
        function do_del(id) {
            var is = window.confirm("确定要删除这条留言吗? ");
            if (is) {
                window.location.href = "delete.php?id=" + id;
            }
        }
    </script>

    <?php
    include "conn.php";
    $category = $conn->query("select * from category");
    ?>
    <a href="show.php">主页|</a>
    <?php
    while ($row = $category->fetch_array()) { ?>
        <a href="show.php?category=<?php echo $row['c_id'] ?>"><?php echo $row['c_name']; ?>|</a>
    <?php
    }
    if (empty($_GET['id'])) {
        die("id参数不能为空!");
    }
    $id = $_GET['id'];
    $sql = "select * from `message`,`category` where id={$id} and message.c_id=category.c_id";
    $result = $conn->query($sql);
    while ($row = $result->fetch_array()) { ?>
        <h3>标题：<?php echo $row['title']; ?>| 分类：<a href="show.php?category=<?php echo $row['c_id'] ?>"><?php echo $row['c_name']; ?></a></h3>
        <p>作者：<?php echo $row['author']; ?>| 发表时间：<?php echo $row['ptime']; ?>| 来自于：<?php echo $row['ip']; ?></p>
        <p>留言内容：<?php echo $row['content']; ?></p>
        <p><a href="edit.php?id=<?php echo $row['id'] ?>">编辑</a> | <a href="javascript:do_del(<?php echo $row['id'] ?>)">删除</a></p>
        <hr>
    <?php
    }
    ?>
</body>

</html>